Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CCIP-4171] integration-tests/smoke/ccip: add re-org tests #16056

Open
wants to merge 13 commits into
base: develop
Choose a base branch
from

Conversation

makramkd
Copy link
Contributor

@makramkd makramkd commented Jan 24, 2025

Add re-org tests that cover the following cases:

  • re-org on source less than finality, should be fine
  • re-org on dest less than finality, should be fine
  • re-org on source greater than finality, that source is no longer processed
  • re-org on dest greater than finality, bridge stops

Copy link
Contributor

github-actions bot commented Jan 24, 2025

AER Report: CI Core

aer_workflow , commit , Detect Changes , Clean Go Tidy & Generate , Scheduled Run Frequency , Core Tests (go_core_tests) , Core Tests (go_core_tests_integration) , Core Tests (go_core_ccip_deployment_tests) , Core Tests (go_core_fuzz) , Core Tests (go_core_race_tests) , GolangCI Lint (.) , test-scripts , GolangCI Lint (integration-tests) , GolangCI Lint (deployment) , lint , SonarQube Scan

1. Possible nil pointer dereference: Golang Lint (integration-tests)

Source of Error:
Golang Lint (integration-tests)	2025-01-29T18:12:16.3663736Z ##[error]integration-tests/testsetups/ccip/test_helpers.go:341:51: SA5011: possible nil pointer dereference (staticcheck)
Golang Lint (integration-tests)	2025-01-29T18:12:16.3664845Z 	t.Logf("extra config tomls: %+v", v1_6TestConfig.ExtraConfigTomls)
Golang Lint (integration-tests)	2025-01-29T18:12:16.3665797Z 	 ^
Golang Lint (integration-tests)	2025-01-29T18:12:16.3667948Z ##[error]integration-tests/testsetups/ccip/test_helpers.go:375:5: SA5011(related information): this check suggests that the pointer can be nil (staticcheck)
Golang Lint (integration-tests)	2025-01-29T18:12:16.3668925Z 	if v1_6TestConfig != nil {
Golang Lint (integration-tests)	2025-01-29T18:12:16.3669246Z 	 ^
Golang Lint (integration-tests)	2025-01-29T18:12:16.3670323Z ##[error]integration-tests/testsetups/ccip/test_helpers.go:343:84: SA5011: possible nil pointer dereference (staticcheck)
Golang Lint (integration-tests)	2025-01-29T18:12:16.3671501Z 	cfg, err := tc.GetChainAndTestTypeSpecificConfig("Smoke", tc.CCIP, v1_6TestConfig.ExtraConfigTomls...)
Golang Lint (integration-tests)	2025-01-29T18:12:16.3673333Z 	 ^

Why: The error indicates that v1_6TestConfig might be nil when accessing its ExtraConfigTomls field, leading to a possible nil pointer dereference.

Suggested fix: Ensure that v1_6TestConfig is not nil before accessing its fields. Add a nil check before the lines where v1_6TestConfig.ExtraConfigTomls is accessed.

AER Report: Operator UI CI ran successfully ✅

aer_workflow , commit

@makramkd makramkd marked this pull request as ready for review January 29, 2025 18:08
@makramkd makramkd requested review from a team, AnieeG and kylesmartin as code owners January 29, 2025 18:08
@makramkd makramkd requested a review from b-gopalswami January 29, 2025 18:08
@cl-sonarqube-production
Copy link

Quality Gate failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube

Catch issues before they fail your Quality Gate with our IDE extension SonarLint SonarLint

}

func (l *DeployedLocalDevEnvironment) GetDevEnvConfig() devenv.EnvironmentConfig {
return *l.devEnvCfg
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nil pointer check

@@ -293,7 +293,22 @@ const (
Base64OverrideEnvVarName = k8s_config.EnvBase64ConfigOverride
)

func GetConfig(configurationNames []string, product Product) (TestConfig, error) {
// GetConfig returns a TestConfig struct with the given configuration names
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏

evm_gas_estimation_buffer = 1000
evm_supports_eip1559 = true
evm_default_gas_limit = 6000000
evm_finality_depth = 10
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit : is the chainlink node config updated as part of this updated finality? if not you can create a similar func like this to update the finality in evmConfig.Chain from the finality mentioned in blockchain.EVMNetwork input param. It's not updated in the existing function because other product do not use finality.

#! FinalityDepth on 2337 overridden to 10.
2337 = """
AutoCreateKey = true
FinalityDepth = 10
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you only need this because of Finality Depth , please check my other comment

bnAfterReorg, err := reorgSourceClient.BlockNumber()
require.NoError(t, err, "error getting block number after reorg")

l.Info().Int64("blockNumberAfterReorg", bnAfterReorg).Msg("block number after reorg")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about a check to validate whether reorg happened? bnAfterReorg < minChainBlockNumberBeforeReorg

l.Info().Msgf("sent CCIP message that will get re-orged, msg id: %x", reorgingMsgEvent.Message.Header.MessageId)

// Run reorg above finality depth
const reorgDepth = 60
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be easier to update if you put something like these into var
ReorgDepthGreaterThanFinality and ReorgDepthLesserThanFinality

Comment on lines +435 to +464
require.Eventually(t, func() bool {
violatedResponses := make(map[string]struct{})
for _, node := range nodeAPIs {
// skip bootstrap nodes, they won't have any logpoller filters
p2pKeys, err := node.MustReadP2PKeys()
require.NoError(t, err)

l.Debug().Msgf("got p2pKeys from node API: %+v", p2pKeys)

require.GreaterOrEqual(t, len(p2pKeys.Data), 1)
if !slices.Contains(nonBootstrapP2PIDs, p2pKeys.Data[0].Attributes.PeerID) {
l.Info().Msgf("skipping bootstrap node w/ p2p id %s", p2pKeys.Data[0].Attributes.PeerID)
continue
}

resp, _, err := node.Health()
require.NoError(t, err)
for _, d := range resp.Data {
if d.Attributes.Name == destLogPollerService &&
d.Attributes.Output == "finality violated" &&
d.Attributes.Status == "failing" {
violatedResponses[p2pKeys.Data[0].Attributes.PeerID] = struct{}{}
break
}
}

if _, ok := violatedResponses[p2pKeys.Data[0].Attributes.PeerID]; ok {
l.Info().Msgf("node %s reported finality violation", p2pKeys.Data[0].Attributes.PeerID)
} else {
l.Info().Msgf("node %s did not report finality violation, log poller response: %+v",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: a wrapper func for checking the finality violation is reported and not reported given the chain details

noreorgSourceSelector := allChains[1]
noreorgSourceChain, ok := chainsel.ChainBySelector(noreorgSourceSelector)
require.True(t, ok)
reorgLogPollerService := fmt.Sprintf("EVM.%d.LogPoller", reorgSourceChain.EvmChainID)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit : func var with this

}, 3*time.Minute, 5*time.Second, "not all the nodes report finality violation")
l.Info().Msg("All nodes reported finality violation")

// expect the commit to still go through on the non-reorged source chain.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you validating that reorged message is not processed

}, 3*time.Minute, 5*time.Second, "not all the nodes report finality violation")
l.Info().Msg("All nodes reported finality violation")

// expect the commit to still go through on the non-reorged source chain.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you validating that reorged message is not processed


// wait for log poller filters to get registered.
l.Info().Msg("waiting for log poller filters to get registered")
time.Sleep(15 * time.Second)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is mostly not enough in in-memory test. Until we have proper solution, I would bump this to 30 sec.

Comment on lines +351 to +368
testhelpers.WithLogMessagesToIgnore([]testhelpers.LogMessageToIgnore{
{
Msg: "Got very old block.",
Reason: "We are expecting a re-org beyond finality",
Level: zapcore.DPanicLevel,
},
{
Msg: "Reorg greater than finality depth detected",
Reason: "We are expecting a re-org beyond finality",
Level: zapcore.DPanicLevel,
},
{
Msg: "Failed to poll and save logs due to finality violation, retrying later",
Reason: "We are expecting a re-org beyond finality",
Level: zapcore.DPanicLevel,
},
}),
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can extract this out as it is similar in the other test as well.

}

l.Info().Msgf("%d nodes reported finality violation", len(violatedResponses))
return len(violatedResponses) == nonBootstrapCount
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How consistently is this works? In v1.5 test, we had flakiness in detecting the violation within given time by all nodes. I have tried some trade offs like certain number of nodes detection and all but it was still flakey. I see your approach of moving forward with certain blocks and then applying the re-org. Is that helps to produce consistent results?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants